﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StructEditor.aspx.cs" Inherits="EuroAudit.StructEditor" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Struktūras redaktors</title>
    <link href="Style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javacript">
        <!--
        function Window_OnUnLoad()
        {
           //On Error Resume Next
           Parent.frames("contents").location.href = "index.aspx";
           //Parent.frames("top").location.href = "top.aspx"
        }
        function RefreshIndex()
        {
           //On Error Resume Next
           top.frames.contents.location = "index.aspx";
           
           //Parent.frames("top").location.href = "top.aspx"
       }
       function OpenModal() {
           var MessageSource = "cmdDel";
           var MessageText = "Struktūras ieraksts tiks dzēsts. Vai turpināt?";
           var WinSettings = "center:yes;resizable:no;dialogHeight:200px;status:no";
           var RetVal = window.showModalDialog("ModalDlg.aspx", MessageText, WinSettings);
           //__doPostBack("cmdDelLn", "");
           //__doPostBack("cmdDel","");
           //$get('cmdDel').click();
           if (document.getElementById("_RESULT").textContent != "undefined")
               document.getElementById("_RESULT").textContent = RetVal + MessageSource;
           if (document.getElementById("_RESULT").innerText != "undefined")
               document.getElementById("_RESULT").innerText = RetVal + MessageSource;
           //document.getElementById('_RESULT').innerText = RetVal + MessageSource;
           __doPostBack('_RESULT', '');
           RefreshIndex();
       }
       function overlay() {
           xyz = document.getElementById("overlay");
           xyz.style.visibility = (xyz.style.visibility == "visible") ? "hidden" : "visible";

       }

        -->
    </script>

</head>
<body class="PageMain">
    <form id="form1" runat="server">
    <div id="overlay">
        <div align="center">
            <asp:Label ID="lblDelStr" runat="server" CssClass="LabelFieldCaption" Text="Struktūras ieraksts tiks dzēsts. Vai turpināt?"></asp:Label>
            <br />
            <asp:Button ID="cmdDelOKStr" runat="server" CssClass="cmdDel" OnClientClick="overlay()"
                OnClick="cmdDel_Click" Text="OK" />
            <asp:Button ID="cmdDelCancel" runat="server" CssClass="cmdClose" OnClientClick="overlay()"
                Text="Cancel" />
        </div>
    </div>    
    <div>
        <div align="center">
            <asp:Label ID="lblCaption" runat="server" CssClass="LabelPageCaption" 
                Text="Struktūras redaktors"></asp:Label>
        </div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <br />
        <asp:Button ID="cmdNew" runat="server" Text="Jauns ieraksts" AccessKey="J" 
            CssClass="cmdNew" onclick="cmdNew_Click" Visible="False" />
        <asp:Button ID="cmdPostBack" runat="server" onclick="cmdPostBack_Click" 
            PostBackUrl="~/StructEditor.aspx" Text="cmdPostBack" Visible="False" />
        <br />
        <asp:UpdatePanel ID="upEdit" runat="server">
            <ContentTemplate>
                
                <asp:Panel ID="pEdit" runat="server" Height="1000px" CssClass="PanelEdit" 
                    Visible="False" Width="100%">
                    <asp:TextBox ID="txtTContID" runat="server" CssClass="FieldsUnvisible"></asp:TextBox>
                    <asp:TextBox ID="txtNodeID" runat="server" CssClass="FieldsUnvisible"></asp:TextBox>
                    <asp:TextBox ID="txtNodePath" runat="server" CssClass="FieldsUnvisible"></asp:TextBox>
                    <a name="pEdit"></a>
                    <br />
                    <asp:Label ID="Label1" runat="server" CssClass="LabelFieldCaption" 
                        Text="Saglabāšanas nosacījumi"></asp:Label>
                    <br />
                    <asp:DropDownList ID="ddlSaveOpt" runat="server" CssClass="FieldsDropDown">
                        <asp:ListItem Value="-1">Pievienot pirms</asp:ListItem>
                        <asp:ListItem Value="0">Aizvietot</asp:ListItem>
                        <asp:ListItem Selected="True" Value="1">Pievienot pēc</asp:ListItem>
                        <asp:ListItem Value="2">Pievienot kā apakšnodaļu</asp:ListItem>
                    </asp:DropDownList>
                    <asp:DropDownList ID="ddlSavePlace" runat="server" CssClass="FieldsDropDown">
                    </asp:DropDownList>
                    <br />
                    <asp:Label ID="Label2" runat="server" CssClass="LabelFieldCaption" 
                        Text="Satura nosaukums"></asp:Label>
                    <br />
                    <asp:TextBox ID="txtTContName" runat="server" CssClass="FieldsText"></asp:TextBox>
                    <br />
                    <asp:Label ID="Label3" runat="server" CssClass="LabelFieldCaption" 
                        Text="Attēlošanas veids"></asp:Label>
                    <br />
                    <asp:DropDownList ID="ddlViewID" runat="server" CssClass="FieldsDropDown" 
                        DataTextField="Nos" DataValueField="NosID">
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="dsViewID" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:WebCNS %>" 
                        ProviderName="<%$ ConnectionStrings:WebCNS.ProviderName %>" 
                        SelectCommand="SELECT NosID, Nos FROM spr WHERE RecStatus=0 AND SprID='ViewID' ORDER BY Nos">
                    </asp:SqlDataSource>
                    <br />
                    <asp:Label ID="Label4" runat="server" CssClass="LabelFieldCaption" 
                        Text="Attēlošanas parametri"></asp:Label>
                    <br />
                    <asp:TextBox ID="txtViewParam" runat="server" CssClass="FieldsText"></asp:TextBox>
                    <br />
                    <asp:Label ID="Label8" runat="server" CssClass="LabelFieldCaption" 
                        Text="Saistītās tabulas nosaukums"></asp:Label>
                    <br />
                    <asp:TextBox ID="txtLinkTbl" runat="server" CssClass="FieldsText"></asp:TextBox>
                    <br />
                    <asp:Label ID="Label5" runat="server" CssClass="LabelFieldCaption" 
                        Text="Pieejas tiesības lietotājiem"></asp:Label>
                    <br />
                    <asp:TextBox ID="txtAccessU" runat="server" CssClass="FieldsText" 
                        ReadOnly="True"></asp:TextBox>
                    <asp:Button ID="cmdAccessU" runat="server" CssClass="cmdShowLists" Text="..." 
                        onclick="cmdAccessU_Click" />
                    <br />
                    <asp:GridView ID="gvAccessU" runat="server" AutoGenerateSelectButton="True" CssClass="TablePopUp" 
                        onselectedindexchanged="gvAccessU_SelectedIndexChanged" Visible="False" 
                        AutoGenerateColumns="False">
                    </asp:GridView>
                    <asp:SqlDataSource ID="dsUsers" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:WebCNS %>" 
                        ProviderName="<%$ ConnectionStrings:WebCNS.ProviderName %>" 
                        SelectCommand="SELECT User, LongName, Groups FROM users ORDER BY User">
                    </asp:SqlDataSource>
                    <br />
                    <asp:Label ID="Label6" runat="server" CssClass="LabelFieldCaption" 
                        Text="Pieejas tiesības grupām"></asp:Label>
                    <br />
                    <asp:TextBox ID="txtAccessG" runat="server" CssClass="FieldsText" 
                        ReadOnly="True"></asp:TextBox>
                    <asp:Button ID="cmdAccessG" runat="server" CssClass="cmdShowLists" Text="..." 
                        onclick="cmdAccessG_Click" />
                    <br />
                    <asp:GridView ID="gvAccessG" runat="server" AutoGenerateColumns="False" 
                        onselectedindexchanged="gvAccessG_SelectedIndexChanged" 
                        Visible="False">
                        <Columns>
                            <asp:CommandField ShowSelectButton="True" />
                            <asp:BoundField DataField="GroupName" HeaderText="GroupName" 
                                SortExpression="GroupName" />
                            <asp:BoundField DataField="Description" HeaderText="Description" 
                                SortExpression="Description" />
                        </Columns>
                    </asp:GridView>
                    <asp:SqlDataSource ID="dsGroups" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:WebCNS %>" 
                        ProviderName="<%$ ConnectionStrings:WebCNS.ProviderName %>" 
                        
                        SelectCommand="SELECT GroupName, Description FROM groups WHERE RecStatus=0 ORDER BY GroupName">
                    </asp:SqlDataSource>
                    <br />
                    <asp:Label ID="Label7" runat="server" CssClass="LabelFieldCaption" 
                        Text="Rediģēšanas tiesības lietotājiem"></asp:Label>
                    <br />
                    <asp:TextBox ID="txtEditU" runat="server" CssClass="FieldsText" ReadOnly="True"></asp:TextBox>
                    <asp:Button ID="cmdEditU" runat="server" CssClass="cmdShowLists" Text="..." 
                        onclick="cmdEditU_Click" />
                    <br />
                    <asp:GridView ID="gvEditU" runat="server" AutoGenerateSelectButton="True" 
                        CssClass="TablePopUp"  
                        onselectedindexchanged="gvEditU_SelectedIndexChanged" Visible="False" 
                        AutoGenerateColumns="False" DataKeyNames="User">
                        <Columns>
                            <asp:BoundField DataField="User" HeaderText="User" ReadOnly="True" 
                                SortExpression="User" />
                            <asp:BoundField DataField="LongName" HeaderText="LongName" 
                                SortExpression="LongName" />
                            <asp:BoundField DataField="Groups" HeaderText="Groups" 
                                SortExpression="Groups" />
                        </Columns>
                    </asp:GridView>
                    <br />
                    <div align="center">
                        <asp:Label ID="lblErr" runat="server" CssClass="LabelError" ForeColor="Red"></asp:Label>
                        <br />
                        <asp:Button ID="cmdSave" runat="server" CssClass="cmdSave" Text="Saglabāt" 
                            onclick="cmdSave_Click" />
                        &nbsp;<asp:Button ID="cmdDel" runat="server" CssClass="cmdDel" Text="Dzēst" 
                            onclick="cmdDel_Click" Visible="False" />
                        &nbsp;<asp:Button ID="cmdDelMod" runat="server" CssClass="cmdDel" 
                            onclientclick="overlay()" Text="Dzēst" />
                        &nbsp;<asp:Button ID="cmdClose" runat="server" CssClass="cmdClose" 
                            Text="Aizvērt" onclick="cmdClose_Click" onclientclick="RefreshIndex()" />
                        <br />
                        <asp:TextBox ID="_RESULT" runat="server" CssClass="FieldsUnvisible"></asp:TextBox>
                    </div>
                </asp:Panel>
                <div align="center">
                
                    <asp:UpdatePanel ID="upList" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:Table ID="tblStruct" runat="server" CssClass="TableList" Width="100%" 
                                GridLines="Horizontal">
                            </asp:Table>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                
                </div>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="cmdNew" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    
    </div>
    </form>
</body>
</html>
